<template>
  <a-popconfirm
      :title="title"
      @confirm="handleSubmit(stationIds)"
      okText="是"
      cancelText="否"
  >
    <a href="#">删除</a>
  </a-popconfirm>
</template>

<script>
import {removeStation} from '@/api/system/station'

export default {
  props: {
    stationIds: {
      type: String
    }
  },
  data () {
    return {
      title: '确定要删除这' + this.stationIds.split(',').length + '条记录吗？'
    }
  },
  watch: {
    stationIds (val) {
      this.title = '确定要删除这' + val.split(',').length + '条记录吗？'
    }
  },
  methods: {
    handleSubmit (stationIds) {
      removeStation({'stationIds': stationIds})
          .then(() => {
            this.$emit('ok')
          }).catch(err => {
        this.$message.error(err.result || '操作失败！')
      })
    }
  }
}
</script>
